# pip install pymysql

# 1.导包
import pymysql

print("")

# 2.建立连接
connect = pymysql.connect(
    host = '192.168.1.12',
    port = 30006,
    user = 'root',
    password = '123456',
    database = 'xeelur',
    charset = 'utf8'
)

# 获取游标?
cursor = connect.cursor()

# 执行sql
cursor.execute("SELECT * FROM `sys_dept`")

# 获取查询结果
one = cursor.fetchone()
print("one")
print(one)
list = cursor.fetchmany(10)
print("list")
print(list)
all = cursor.fetchall();
print("all")
print(all)

# 关闭资源
cursor.close()
connect.close()